package com.zliblike_platform.controller;

import com.zliblike_platform.service.RankingService;
import com.zliblike_platform.vo.RankingVO;
import com.zliblike_platform.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 排行榜控制器
 */
@Controller
@RequestMapping("/ranking")
public class RankingController {

    @Autowired
    private RankingService rankingService;

    /**
     * 激励机制详情页
     *
     * @return 视图名称
     */
    @GetMapping("/incentive")
    public String incentivePage() {
        return "incentive";
    }

    /**
     * 获取总积分排行榜
     *
     * @param limit 限制返回数量
     * @return 排行榜数据
     */
    @GetMapping("/api/total")
    @ResponseBody
    public ResultVO<List<RankingVO>> getTotalRanking(
            @RequestParam(defaultValue = "10") Integer limit) {
        List<RankingVO> rankingList = rankingService.getTotalRanking(limit);
        return ResultVO.success(rankingList);
    }

    /**
     * 获取上传积分排行榜
     *
     * @param limit 限制返回数量
     * @return 排行榜数据
     */
    @GetMapping("/api/upload")
    @ResponseBody
    public ResultVO<List<RankingVO>> getUploadRanking(
            @RequestParam(defaultValue = "10") Integer limit) {
        List<RankingVO> rankingList = rankingService.getUploadRanking(limit);
        return ResultVO.success(rankingList);
    }

    /**
     * 获取编辑积分排行榜
     *
     * @param limit 限制返回数量
     * @return 排行榜数据
     */
    @GetMapping("/api/edit")
    @ResponseBody
    public ResultVO<List<RankingVO>> getEditRanking(
            @RequestParam(defaultValue = "10") Integer limit) {
        List<RankingVO> rankingList = rankingService.getEditRanking(limit);
        return ResultVO.success(rankingList);
    }
} 